<template>
	<view class="">
		<view class="" v-if="stor == 1">
			<view v-for="(item,index) in imageList" :key="index" @click="preViewImg(imageList,index)">
				<image
				:src="item" 
				mode="widthFix"
				style="width: 100%;display: block;"></image>
			</view>
		</view>
		<view class="mainCon" v-else>
			<jyf-parser :html="content"></jyf-parser>
		</view>
		<mix-loading v-if="isLoading"></mix-loading>
	</view>
</template>

<script>
import jyfParser from '@/components/jyf-parser/jyf-parser.vue';
export default {
	components: {
		jyfParser
	},
	data() {
		return {
			content: '',
			type: '',
			imageList:[],
			stor:''
		};
	},
	onLoad(options) {
		if (options.type) this.type = options.type;
		if (options.name) this.setNavTitle(options.name);
		if(options.stor){
			this.stor = options.stor
			this.imageList = getApp().globalData.urlImage.split('|')
		}else{
			this.loadData();
		}
	},
	methods: {
		// 预览图片
		preViewImg(image, index) {
			if (typeof(image) === 'string') {
				image = [image]
			}
			uni.previewImage({
				current: index || 0,
				urls: image,
				indicator: 'number'
			})
		},
		async loadData() {
			const res = await this.$request('content/rich-text', { type: this.type }, { showLoading: true });
			if (res.result == 0) {
				this.content = res.data.detail;
			} else {
				this.$util.msg(res.resultNote);
			}
		}
	}
};
</script>

<style scoped>
.mainCon {
	padding: 20upx;
}
</style>
